#include "dev_tree.h"

dev_tree_t dev_tree = {

    .gpioa_8 = {
        .port         = GPIOA,
        .pin          = GPIO_PIN_8,
        .mode         = GPIO_MODE_OUTPUT,
        .otype        = GPIO_OTYPE_PP,
        .pull         = GPIO_PUPD_NONE,
        .speed        = GPIO_OSPEED_2MHZ,
    };

#if(GD_UART0_STATUS == ES_ENABLE)
    .usart0 = 
    {
        .usart_periph     = USART0,
        .rcu_clk          = RCU_USART0,
        .baudrate         = 115200,
        .data_len         = USART_WL_8BIT,
        .parity           = USART_PM_NONE,
        .stop_bit         = USART_STB_1BIT,
        .irq              = USART0_IRQn,
        .pre_priority     = 5,
        .sub_priority     = 0,
        .uart_mode        = TX_ENABLE | RX_ENABLE,
        .rec_len          = 0,
        .rec_max          = 256,

        .tx_pin = 
        {
            .port         = GPIOA,
            .pin          = GPIO_PIN_9,
            .mode         = GPIO_MODE_AF,
            .otype        = GPIO_OTYPE_PP,
            .pull         = GPIO_PUPD_PULLUP,
            .speed        = GPIO_OSPEED_50MHZ,
            .alt_func     = GPIO_AF_7,
        },

        .rx_pin = 
        {
            .port         = GPIOA,
            .pin          = GPIO_PIN_10,
            .mode         = GPIO_MODE_AF,
            .otype        = GPIO_OTYPE_PP,
            .pull         = GPIO_PUPD_PULLUP,
            .speed        = GPIO_OSPEED_50MHZ,
            .alt_func     = GPIO_AF_7,
        },

        .tx_dma = 
        {
            .rcu_clk      = RCU_DMA1,
            .dma_periph   = DMA1,
            .channel      = DMA_CH7,
            .sub_periph   = DMA_SUBPERI4,
            .irq          = DMA1_Channel7_IRQn,
            .pre_priority = 0,
            .sub_priority = 0,
            .tran_int     = DMA_INT_FTF,
            .tran_buff    = NULL,

            .dma_init     = {
                .direction           = DMA_MEMORY_TO_PERIPH,
                .memory0_addr        = NULL,
                .memory_inc          = DMA_MEMORY_INCREASE_ENABLE,
                .periph_memory_width = DMA_MEMORY_WIDTH_8BIT,
                .number              = 0,
                .periph_addr         = (uint32_t)&USART_DATA(USART0),
                .periph_inc          = DMA_PERIPH_INCREASE_DISABLE,
                .priority            = DMA_PRIORITY_ULTRA_HIGH,
                .circular_mode       = DMA_CIRCULAR_MODE_DISABLE,
            },
        },

        .rx_dma = 
        {
            .rcu_clk      = RCU_DMA1,
            .dma_periph   = DMA1,
            .channel      = DMA_CH2,
            .sub_periph   = DMA_SUBPERI4,
            .irq          = DMA1_Channel2_IRQn,
            .pre_priority = 0,
            .sub_priority = 0,
            .tran_int     = DMA_INT_FTF,
            .tran_buff    = NULL,

            .dma_init     = {
                .direction           = DMA_PERIPH_TO_MEMORY,
                .memory0_addr        = NULL,
                .memory_inc          = DMA_MEMORY_INCREASE_ENABLE,
                .periph_memory_width = DMA_MEMORY_WIDTH_8BIT,
                .number              = 0,
                .periph_addr         = (uint32_t)&USART_DATA(USART0),
                .periph_inc          = DMA_PERIPH_INCREASE_DISABLE,
                .priority            = DMA_PRIORITY_ULTRA_HIGH,
                .circular_mode       = DMA_CIRCULAR_MODE_DISABLE,
            },
        },
    },
#endif

#if(GD_UART7_STATUS == ES_ENABLE)
    .uart7 = 
    {
        .usart_periph     = UART7,
        .rcu_clk          = RCU_UART7,
        .baudrate         = 115200,
        .data_len         = USART_WL_8BIT,
        .parity           = USART_PM_NONE,
        .stop_bit         = USART_STB_1BIT,
        .irq              = UART7_IRQn,
        .pre_priority     = 5,
        .sub_priority     = 0,
        .uart_mode        = TX_ENABLE | RX_ENABLE,
        .rec_len          = 0,
        .rec_max          = 256,

        .tx_pin = 
        {
            .port         = GPIOE,
            .pin          = GPIO_PIN_1,
            .mode         = GPIO_MODE_AF,
            .otype        = GPIO_OTYPE_PP,
            .pull         = GPIO_PUPD_PULLUP,
            .speed        = GPIO_OSPEED_50MHZ,
            .alt_func     = GPIO_AF_8,
        },

        .rx_pin = 
        {
            .port         = GPIOE,
            .pin          = GPIO_PIN_0,
            .mode         = GPIO_MODE_AF,
            .otype        = GPIO_OTYPE_PP,
            .pull         = GPIO_PUPD_PULLUP,
            .speed        = GPIO_OSPEED_50MHZ,
            .alt_func     = GPIO_AF_8,
        },

        .tx_dma = 
        {
            .rcu_clk      = RCU_DMA0,
            .dma_periph   = DMA0,
            .channel      = DMA_CH0,
            .sub_periph   = DMA_SUBPERI5,
            .irq          = DMA0_Channel0_IRQn,
            .pre_priority = 0,
            .sub_priority = 0,
            .tran_int     = DMA_INT_FTF,
            .tran_buff    = NULL,

            .dma_init     = {
                .direction           = DMA_MEMORY_TO_PERIPH,
                .memory0_addr        = NULL,
                .memory_inc          = DMA_MEMORY_INCREASE_ENABLE,
                .periph_memory_width = DMA_MEMORY_WIDTH_8BIT,
                .number              = 0,
                .periph_addr         = (uint32_t)&USART_DATA(UART7),
                .periph_inc          = DMA_PERIPH_INCREASE_DISABLE,
                .priority            = DMA_PRIORITY_ULTRA_HIGH,
                .circular_mode       = DMA_CIRCULAR_MODE_DISABLE,
            },
        },

        .rx_dma = 
        {
            .rcu_clk      = RCU_DMA0,
            .dma_periph   = DMA0,
            .channel      = DMA_CH6,
            .sub_periph   = DMA_SUBPERI5,
            .irq          = DMA0_Channel6_IRQn,
            .pre_priority = 0,
            .sub_priority = 0,
            .tran_int     = DMA_INT_FTF,
            .tran_buff    = NULL,

            .dma_init     = {
                .direction           = DMA_PERIPH_TO_MEMORY,
                .memory0_addr        = NULL,
                .memory_inc          = DMA_MEMORY_INCREASE_ENABLE,
                .periph_memory_width = DMA_MEMORY_WIDTH_8BIT,
                .number              = 0,
                .periph_addr         = (uint32_t)&USART_DATA(UART7),
                .periph_inc          = DMA_PERIPH_INCREASE_DISABLE,
                .priority            = DMA_PRIORITY_ULTRA_HIGH,
                .circular_mode       = DMA_CIRCULAR_MODE_DISABLE,
            },
        },
    },
#endif
};


